﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace E_mail
{
    /// <summary>
    /// Interaction logic for WindowPassword.xaml
    /// </summary>
    public partial class WindowPassword : Window
    {
        private AccountPropertis propertis;

        public WindowPassword()
        {
            InitializeComponent();
            passwordBox1.Focus();
        }

        public WindowPassword(AccountPropertis propertis):this()
        {
            this.propertis = propertis;
        }

        private void btn_Ok_Click(object sender, RoutedEventArgs e)
        {
            if (String.IsNullOrEmpty(passwordBox1.Password))
            {
                MessageBox.Show("Musisz wpisać hasło", "Info", MessageBoxButton.OK, MessageBoxImage.Asterisk);
                return;
            }

            propertis.Password = passwordBox1.Password;
            DialogResult = true;
        }

        private void btn_Cancel_Click(object sender, RoutedEventArgs e)
        {
            DialogResult = false;
        }

        private void passwordBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
                btn_Ok_Click(this, e);
        }

    }
}
